package com.smart.service;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import com.smart.model.Menu;
import com.smart.model.MenuCond;

/**
 * 
 * @author Sunxin
 *
 */
 
@Transactional(readOnly=true)
public interface MenuService extends BaseService<Menu, MenuCond, Long>{
	
	@Cacheable(value="menuCache", key="#id")
	public Menu findOne(Long id);
	/**
	 * 获取整个菜单树
	 * @param rootNodeId 根节点id
	 * @return
	 */
	@Cacheable(value="menuCache", key="#rootNodeId")
	Menu getMenuTree(long rootNodeId);
	
	/**
	 * 获取整个菜单树
	 * @param rootNodeCode 根节点code
	 * @return
	 */
	@Cacheable(value="menuCache", key="#rootNodeCode")
	Menu getMenuTree(String rootNodeCode);
	
	/**
	 * 将树状结构的Menu扁平化
	 * @param menu
	 * @return
	 */
	List<Menu> toPlainStructure(Menu menu);
	
	@CacheEvict(value="menuCache", allEntries=true)
	public void removeCache();
}
